package com.lianzhihui.romeex.bean;

import com.lianzhihui.romeex.MyApplication;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.utils.LogUtil;
import com.lianzhihui.romeex.utils.UserUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.bean
 * @ClassName: TradeRecordBean
 * @Description: java类作用描述
 * @Author: zhanghong
 * @CreateDate: 2020/11/11 11:00
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/11/11 11:00
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class TradeRecordBean implements Serializable {

    /**
     * pages : 1
     * pageSize : 10
     * page : 1
     * coinName : RET
     * coinNameCobo : RET
     * tradeType : 0
     * content : [{"amount":"0.00000002","sourceAddress":"13yNMZ2RSqM2ho7MRAFFMsJdrcjZWWxTQ3","transactionHashcode":"0x2c1b4820cd83f2eef7015e53a747f0dd0b195630eb5d7f441094b110b7dc8a56c","targetAddress":"16ntyd9C4xoeru15jhugy3G5X8JQt6wbzG","traceStatus":5,"confirmedNum":0,"chainType":1,"transactionType":"100","confirmMainTime":1604576302000,"confirmingthreshold":0,"isOut":true,"timestamp":1604576301000,"height":59344}]
     */

    public int pages;
    public int pageSize;
    public int page;
    public String coinName;
    public String coinNameCobo;
    public int tradeType;

    public double validBalance;//可用余额
    public double lockBalance;//冻结余额
    public double profitBalance;//收益余额
    public double totalBalance;//总金额
    public double price;//美元价格
    public double priceCny;//人民币


    public double getValidBalance() {
        return validBalance;
    }

    public void setValidBalance(double validBalance) {
        this.validBalance = validBalance;
    }

    public double getLockBalance() {
        return lockBalance;
    }

    public void setLockBalance(double lockBalance) {
        this.lockBalance = lockBalance;
    }

    public double getProfitBalance() {
        return profitBalance;
    }

    public void setProfitBalance(double profitBalance) {
        this.profitBalance = profitBalance;
    }

    public double getTotalBalance() {
        return totalBalance;
    }

    public void setTotalBalance(double totalBalance) {
        this.totalBalance = totalBalance;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getPriceCny() {
        return priceCny;
    }

    public void setPriceCny(double priceCny) {
        this.priceCny = priceCny;
    }

    public List<DetailBean> content;

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public String getCoinName() {
        return coinName;
    }

    public void setCoinName(String coinName) {
        this.coinName = coinName;
    }

    public String getCoinNameCobo() {
        return coinNameCobo;
    }

    public void setCoinNameCobo(String coinNameCobo) {
        this.coinNameCobo = coinNameCobo;
    }

    public int getTradeType() {
        return tradeType;
    }

    public void setTradeType(int tradeType) {
        this.tradeType = tradeType;
    }

    public List<DetailBean> getContent() {
        if (content == null) {
            return new ArrayList<>();
        } else {
            return content;
        }
    }

    public void setContent(List<DetailBean> content) {
        this.content = content;
    }

    public static class DetailBean implements Serializable {

//        "amount":"3",
//                "sourceAddress":"13yNMZ2RSqM2ho7MRAFFMsJdrcjZWWxTQ3",
//                "transactionHashcode":"0x23ac9c0d2e93ff3a3b632aaa3fe0636fc1bead197f230b8c0c49bfb6601eab254",
//                "browserUri":"",
//                "targetAddress":"0x3346b81a32e7007eccadf60252bb599f0",
//                "traceStatus":5,
//                "confirmedNum":0,
//                "remark":"RET,USDT",
//                "chainType":1,
//                "transactionType":"7",
//                "confirmMainTime":1606964606000,
//                "confirmingthreshold":0,
//                "isOut":true,
//                "coinName":"RET",
//                "coinNameCobo":"RET",
//                "timestamp":1606964602000,
//                "height":536978

        public String amount;
        public String sourceAddress;
        public String browserUri;
        public String transactionHashcode;
        public String targetAddress;
        public int traceStatus;
        public int confirmedNum;
        public int chainType;
        public int transactionType;
        public long confirmMainTime;
        public int confirmingthreshold;
        public boolean isOut;
        public String timestamp;
        public int height;
        public String coinNameCobo;
        public String coinName;
        public String remark;
        public String crossBrowserUri;
        public String fee;
        public String feeCoinName;

        public String getCrossBrowserUri() {
            return crossBrowserUri;
        }

        public void setCrossBrowserUri(String crossBrowserUri) {
            this.crossBrowserUri = crossBrowserUri;
        }

        public String getBrowserUri() {
            return browserUri;
        }

        public void setBrowserUri(String browserUri) {
            this.browserUri = browserUri;
        }

        public boolean isOut() {
            return isOut;
        }

        public void setOut(boolean out) {
            isOut = out;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public String getTitle() {
            switch (transactionType) {
                case 1:
                    //转账
                    if (isOut) {
                        return "转账记录";

                    } else {
                        return "收款记录";

                    }

                case 2:  //交易所充值
                    break;
                case 3:  //头矿奖励
                    break;
                case 4:  //跨链交易
                    //转账
                    return "转账详情";
                case 5:  //退款(不用判断isOut)
                    break;
                case 6:  //手续费(不用判断isOut)
                    break;
                case 7:  //兑换(不用判断isOut)
                    if (null != remark && !remark.isEmpty()) {
                        String[] split = remark.split(",");
                        return split[0] + MyApplication.mContext.getResources().getString(R.string.text_exchange) + split[1];
                    }
                    break;
                case 8:  //质押(不用判断isOut)
                    return MyApplication.mContext.getResources().getString(R.string.text_pledge);
                case 9:  //提取(不用判断isOut)
                    return MyApplication.mContext.getResources().getString(R.string.pledge_confirm_take_out);
                case 10:  //划转
                    if (isOut) {
                        return "从可用余额到收益余额";
                    } else {
                        return "从收益余额到可用余额";
                    }
                    //其他
                case 13:  //购买节点
                    return "购买节点";
                    //其他
                default:
                    return getOtherAddress();

            }
            return getOtherAddress();
        }

        public String getTradeTypeStr() {
            LogUtil.error("ramon", "transactionType: " + transactionType);
            LogUtil.error("ramon", "isout: " + isOut);
            switch (transactionType) {
                case 1:
                    if (isOut) {
                        return "转账成功";
                    } else {
                        return "收款成功";
                    }
                case 2:
                    if (isOut) {
                        return "转账成功";
                    } else {
                        return "收款成功";
                    }
                case 3:
                    if (isOut) {
                        return "无";
                    } else {
                        return "头矿收益";
                    }

                case 4:
                    if (isOut) {
                        switch (getTraceStatus()) {
                            case 1:
                                return "提现中";
                            case 5:
                                return "提现成功";
                            default:
                                break;
                        }
                    } else {
                        switch (getTraceStatus()) {
                            case 1:
                                return "确定中";
                            case 5:
                                return "充值成功";
                            default:
                                break;
                        }
                    }
                case 5:
                    return "退款成功";
                case 6:
                    return "手续费";
                case 10:
                    return "划转成功";
                case 13:  //购买节点
                    return "购买节点";
                default:
                    break;
            }
            return "";
        }

        public String getOtherAddress() {
//            String address = "";
//            switch (transactionType) {
//                case 1:
//                case 2:
//                case 4:
//                    if (isOut) {
//                        address = getTargetAddress();
//                    } else {
//                        address = getSourceAddress();
//                    }
//                    break;
//                case 3:
//                case 5:
//                    address = getSourceAddress();
//                    break;
//                case 6:
//                    address =getTargetAddress();
//                    break;
//
//                default:
//                    break;
//            }

            String myAddress = UserUtils.getCurrentUserAddress();
            if (myAddress.equals(getSourceAddress())) {
                return getTargetAddress();
            } else {
                return getSourceAddress();
            }
        }

        public String getAmount() {
            return amount;
        }

        public void setAmount(String amount) {
            this.amount = amount;
        }

        public String getSourceAddress() {
            return sourceAddress;
        }

        public void setSourceAddress(String sourceAddress) {
            this.sourceAddress = sourceAddress;
        }

        public String getTransactionHashcode() {
            return transactionHashcode;
        }

        public void setTransactionHashcode(String transactionHashcode) {
            this.transactionHashcode = transactionHashcode;
        }

        public String getTargetAddress() {
            return targetAddress;
        }

        public void setTargetAddress(String targetAddress) {
            this.targetAddress = targetAddress;
        }

        public int getTraceStatus() {
            return traceStatus;
        }

        public void setTraceStatus(int traceStatus) {
            this.traceStatus = traceStatus;
        }

        public int getConfirmedNum() {
            return confirmedNum;
        }

        public void setConfirmedNum(int confirmedNum) {
            this.confirmedNum = confirmedNum;
        }

        public int getChainType() {
            return chainType;
        }

        public void setChainType(int chainType) {
            this.chainType = chainType;
        }

        public int getTransactionType() {
            return transactionType;
        }

        public void setTransactionType(int transactionType) {
            this.transactionType = transactionType;
        }

        public long getConfirmMainTime() {
            return confirmMainTime;
        }

        public void setConfirmMainTime(long confirmMainTime) {
            this.confirmMainTime = confirmMainTime;
        }

        public int getConfirmingthreshold() {
            return confirmingthreshold;
        }

        public void setConfirmingthreshold(int confirmingthreshold) {
            this.confirmingthreshold = confirmingthreshold;
        }

        public boolean isIsOut() {
            return isOut;
        }

        public void setIsOut(boolean isOut) {
            this.isOut = isOut;
        }

        public String getTimestamp() {
            return timestamp;
        }

        public void setTimestamp(String timestamp) {
            this.timestamp = timestamp;
        }

        public int getHeight() {
            return height;
        }

        public void setHeight(int height) {
            this.height = height;
        }

        public String getCoinNameCobo() {
            return coinNameCobo;
        }

        public void setCoinNameCobo(String coinNameCobo) {
            this.coinNameCobo = coinNameCobo;
        }

        public String getCoinName() {
            return coinName;
        }

        public void setCoinName(String coinName) {
            this.coinName = coinName;
        }

        public String getFee() {
            return fee;
        }

        public void setFee(String fee) {
            this.fee = fee;
        }

        public String getFeeCoinName() {
            return feeCoinName;
        }

        public void setFeeCoinName(String feeCoinName) {
            this.feeCoinName = feeCoinName;
        }
    }


}
